package com.lin.maker.command;

import com.lin.maker.model.MainTemplate;
import lombok.Data;
import picocli.CommandLine;

@CommandLine.Command(name = "testGroup", description = "测试参数组(套娃)",mixinStandardHelpOptions = true)
public class TestGroupCommand implements Runnable {
    @CommandLine.Option(names = {"-l", "--loop"}, description = "是否循环",interactive = true, arity = "0..1",echo = true)
    private boolean loop;
    @CommandLine.Option(names = {"-need","needGit"},description = "是否需要git",interactive = true,arity = "0..1",echo = true)
    private boolean needGit;
    static MainTemplate mainTemplate = new MainTemplate();
    @Override
    public void run() {
        System.out.println(needGit);
        System.out.println(loop);
        if(true){
            System.out.println("输入核心内层子命令类");
            CommandLine commandLine = new CommandLine(MainTemplateCommand.class);
            commandLine.execute("-a","-o");
            System.out.println(mainTemplate);
        }
    }

    @CommandLine.Command(name = "mainTemplate", description = "主模板",mixinStandardHelpOptions = true)
    @Data
    static class MainTemplateCommand implements Runnable{
        /**
         * 作者名称
         */
        @CommandLine.Option(names = {"-a", "--author"}, description = "作者",interactive = true, arity = "0..1",echo = true)
        private String author = "lin";

        /**
         * 结果输出
         */
        @CommandLine.Option(names = {"-o", "--output"}, description = "输出",interactive = true, arity = "0..1",echo = true)
        private String output = "sum = ";

        @Override
        public void run() {
            mainTemplate.setAuthor(author);
            mainTemplate.setOutput(output);
        }
    }
    public static void main(String[] args) {
        CommandLine commandLine = new CommandLine(TestGroupCommand.class);
        commandLine.execute("-l", "-need");
//        commandLine.execute("--help");
    }
}
